package com.abei.gas.controller;

import com.abei.gas.entity.Card;
import com.abei.gas.entity.Device;
import com.abei.gas.entity.Employee;
import com.abei.gas.service.DeviceService;
import com.abei.gas.service.EmployeeService;
import com.abei.gas.vo.DataVo;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

@RestController
@RequestMapping("/employee")
@Api(tags = "员工管理相关接口")
public class EmployeeController {
    @Autowired
    private EmployeeService employeeService;

    @GetMapping("/findAll")
    public DataVo<Employee> findAll(Integer page, Integer limit){
        return employeeService.findAll(page,limit);
    }

    @RequestMapping("/deleteById")
    public void deleteById(HttpServletRequest request){
        String id = request.getParameter("id");
        employeeService.deleteById(id);
    }
    /*
     * 添加
     */
    @PostMapping("/insert")
    public void insert(@RequestBody Employee employee){
        employeeService.Insert(employee);
    }

    @RequestMapping("/updateById")
    public void updateById(@RequestBody Employee employee){
        String number=employee.getId();
        employeeService.Update(number,employee);
    }

    //搜索
    @GetMapping("/selectById")
    public DataVo<Employee> selectById(HttpServletRequest request) {
        String id = request.getParameter("id");
        return employeeService.findById(id);
    }
}
